<@sys.role id=id>
    <#assign a=object/>
</@sys.role>
<form method="post" autocomplete="off" action="sysRole/save?callbackType=closeCurrent&navTabId=sysRole/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}"/>
    <input type="hidden" name="_csrf" value="<@tools.csrfToken admin=true/>"/>
    <div class="formBar card">
        <ul>
            <li><button type="submit" class="buttonActive" title="ctrl+s"><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="card">
        <div class="pageFormContent" layoutH>
            <dl class="nowrap">
                <dt><@t.page 'name'/>:</dt>
                <dd>
                    <input class="required" name="name" type="text" maxlength="20" size="20" value="${(a.name)!}"/>
                </dd>
            </dl>
            <dl class="nowrap">
                <dt><@t.page 'module.own_all_right'/>:</dt>
                <dd>
                    <input name="ownsAllRight" type="checkbox"/>
                </dd>
            </dl>
    <#macro moduleTree parentId='' deep=0>
        <@sys.moduleList parentId=parentId advanced=true>
            <#if page.totalCount gt 0>
                <ul>
                <#list page.list as a>
                    <li>
                        <a tname="moduleIds" tvalue="${a.id}"><#if (a.attached)?has_content><i class="${a.attached} icon-large"></i></#if> <@t.menu a.id/></a>
                        <#if deep lte 3>
                            <@moduleTree a.id deep+1/>
                        </#if>
                    </li>
                </#list>
                </ul>
            </#if>
        </@sys.moduleList>
    </#macro>
            <fieldset class="ownsAllRight">
                <legend><@t.page 'module'/></legend>
                <dl class="nowrap">
                    <dt><@t.page 'module.show_all_module'/>:</dt>
                    <dd>
                        <input name="showAllModule" type="checkbox"/>
                    </dd>
                </dl>
                <ul class="tree treeFolder treeCheck">
                    <li>
                        <a href="javascript:;" onclick="return false;"><@t.page 'module.all'/></a>
                        <@moduleTree deep=0/>
                    </li>
                </ul>
    <script>
    $('input[name=ownsAllRight]',navTab.getCurrentPanel()).click(function(){
        if($(this).is(':checked')) {
            $('.ownsAllRight',navTab.getCurrentPanel()).hide();
        } else {
            $('.ownsAllRight').show();
        }
    });
<#if a?has_content>
        <#if a.ownsAllRight>
        $('input[name=ownsAllRight]',navTab.getCurrentPanel()).click();
        </#if>
        <#if a.showAllModule>
        $('input[name=showAllModule]',navTab.getCurrentPanel()).click();
        </#if>
        <@sys.roleModuleList roleId=a.id>
            <#list page.list as a>
        $('.tree li a[tname=moduleIds][tvalue=${a.id.moduleId?js_string}]',navTab.getCurrentPanel()).attr('checked','true');
            </#list>
        </@sys.roleModuleList>
</#if>
    </script>
            </fieldset>
        </div>
    </div>
</form>